BX.namespace("BX.Desktop.Field.Enum");BX.Desktop.Field.Enum=function(e){this.fieldName=null;this.container=null;this.valueContainerId=null;this.value=null;this.items=null;this.defaultFieldName=null;this.block=null;this.formName=null;this.params={};this.init(e)};BX.Desktop.Field.Enum.prototype={init:function(e){this.fieldName=e["fieldName"]||"";this.container=BX(e["container"]);this.valueContainerId=e["valueContainerId"]||"";this.value=e["value"];this.items=e["items"];this.block=e["block"];this.defaultFieldName=e["defaultFieldName"]||this.fieldName+"_default";this.formName=e["formName"]||"";this.params=e["params"]||{};this.bindElement()},bindElement:function(){this.container.appendChild(BX.decl({block:this.block,name:this.fieldName,items:this.items,value:this.value,params:this.params,valueDelete:false}));BX.addCustomEvent(window,"UI::Select::change",this.onChange.bind(this));BX.bind(this.container,"click",BX.defer(function(){this.onChange({params:this.params,node:this.container.firstChild})}.bind(this)))},onChange:function(e,i){if(!BX(this.valueContainerId)){return}var t=null;if(e.node!==null&&e.node.getAttribute("data-name")===this.fieldName){t=JSON.parse(e.node.getAttribute("data-value"))}else{return}this.changeValue(t)},changeValue:function(e){var i="";if(!BX.type.isArray(e)){if(e===null){e=[{VALUE:""}]}else{e=[e]}}if(e.length>0){for(var t=0;t<e.length;t++){i+='<input type="hidden" name="'+this.fieldName+'" value="'+BX.util.htmlspecialchars(e[t].VALUE)+'" />'}}else{i+='<input type="hidden" name="'+this.fieldName+'" value="" />'}BX(this.valueContainerId).innerHTML=i;BX.fireEvent(BX(this.defaultFieldName),"change")}};
//# sourceMappingURL=desktop.map.js